package com.moore.mapper;

import com.moore.bean.Family;
import com.moore.bean.Tenant;
import com.moore.bean.TenantInfo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import javax.print.DocFlavor;
import java.util.List;
import java.util.Map;

public interface TenantMapper {
    int registerTenant(@Param("tenant")Tenant tenant);

    List<Tenant> queryTenant(@Param("account") String account, @Param("password") String password);

    int saveTenantInfo(@Param("tenantInfo") TenantInfo tenantInfo);

    int saveTenantFamily(@Param("families")List<Family> families);

    int updateTenant(@Param("tenant") Tenant tenant);

    List<TenantInfo> queryTenantInfo(@Param("tenant") String tenant);

    List<Family> queryTenantFamily(@Param("tenant") String tenant);

    int updateTenantInfo(@Param("tenantInfo") TenantInfo tenantInfo);

    int deleteTenantFamily(@Param("tenant") String tenant, @Param("realName") String realName);

    @Select("SELECT DATE_FORMAT(created_at, '%Y-%m') AS month, COUNT(*) AS count FROM tenant GROUP BY month ORDER BY month ASC")
    List<Map<String, Object>> getTenantCountByMonth();

}
